<template>
  <div>
    <base-list ref="wrongList"
               :condition="condition"
               :datas.sync="wrongData"
               :pageSearch="pageSearch">
      <el-form :inline="true"
               :model="condition"
               class="search-form"
               slot="search"
               ref="aList"
               label-width="100px">
        <el-row>
          <el-col :span="6"
                  class="search-width6">
            <el-form-item label="处理状态">
              <el-select v-model="condition['search_EQ_auditStatus']"
                         placeholder="请选择"
                         clearable
                         filterable>
                <el-option v-for="[key, val] in _dictAuditStatus"
                           :key="key"
                           :label="val"
                           :value="key"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6"
                  class="search-width6">
            <el-form-item label="盘点计划">
              <auto-search-org v-model="condition['search_EQ_controlOrgName']"
                               placeholder="请选择"
                               @selectName="v=>condition['search_EQ_controlOrgName']=v"
                               :allOrg="true"
                               :name="form.controlOrgName"></auto-search-org>
            </el-form-item>
          </el-col>
          <el-col :span="6"
                  class="search-width6">
            <el-form-item label="跟踪号">
              <auto-search-org v-model="condition['search_EQ_controlOrgName']"
                               placeholder="请选择"
                               @selectName="v=>condition['search_EQ_controlOrgName']=v"
                               :allOrg="true"
                               :name="form.controlOrgName"></auto-search-org>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-button type="primary"
                       icon="el-icon-search"
                       @click="loadData">查 询</el-button>
            <el-button @click="handleStorehouseDialog">修正库位</el-button>
            <el-button @click="handleStockDialog">调整库存</el-button>
          </el-col>
        </el-row>
      </el-form>
      <el-table slot="list"
                :data="wrongData"
                border
                stripe
                highlight-current-row
                @current-change="handleCurrentChange"
                max-height="500">
        <el-table-column label="序号"
                         type="index"
                         width="50"></el-table-column>
        <el-table-column prop="planNo"
                         label="盘点计划"
                         min-width="200"></el-table-column>
        <el-table-column prop="trackingNo"
                         label="跟踪号"
                         min-width="200"></el-table-column>
        <el-table-column prop="exceptionMsg"
                         label="有误信息"
                         min-width="200"></el-table-column>
        <el-table-column prop="status"
                         label="处理状态"
                         min-width="200">
          <template slot-scope="scope">
            {{ scope.row.status | _filterHandleStatus }}
          </template>
        </el-table-column>
        <el-table-column prop="cargoName"
                         label="盘点品名"
                         min-width="200"></el-table-column>
        <el-table-column prop="inventoryNum"
                         label="件数"
                         min-width="150"></el-table-column>
        <el-table-column prop="inventoryWeight"
                         label="重量"
                         min-width="120"></el-table-column>
        <el-table-column prop="inventoryCount"
                         label="数量"
                         min-width="120"></el-table-column>
        <el-table-column prop="normStr"
                         label="规格"
                         min-width="120"></el-table-column>
        <el-table-column prop="material"
                         label="材质"
                         min-width="120"></el-table-column>
        <el-table-column prop="madeBy"
                         label="生产厂家"
                         min-width="120"></el-table-column>
        <el-table-column prop="roomLocation"
                         label="库位"
                         min-width="120"></el-table-column>
        <el-table-column prop="jobBy"
                         label="盘点人"
                         min-width="120"></el-table-column>
        <el-table-column prop="jobTime"
                         label="盘点时间"
                         min-width="120"></el-table-column>
        <el-table-column prop="handleBy"
                         label="处理人"
                         min-width="120"></el-table-column>
        <el-table-column prop="handleTime"
                         label="处理时间"
                         min-width="120"></el-table-column>
        <el-table-column prop="urls"
                         label="上传信息"
                         min-width="120"></el-table-column>
      </el-table>
    </base-list>
    <div style="text-align:center">
      <el-button plain
                 type="info"
                 @click="handleRouterPush({path:'/goods/matter',name:'实物管理工作台'})">返回</el-button>
    </div>
    <mod-storehouse-form ref="modStorehouseForm"
                         @load="loadData"></mod-storehouse-form>
    <adjust-stock-form ref="adjustStockForm"
                       @load="loadData"></adjust-stock-form>
  </div>
</template>

<script>
import { getCheackWrongList } from '@/api/matter/cheackPlan'
import autoSearchOrg from '@/components/autocomplete/autoSearchOrg'
import autoSearchName from '@/components/autocomplete/autoSearchName'
import modStorehouseForm from './modStorehouseForm'
import adjustStockForm from './adjustStockForm'

export default {
  name: 'wrongList',
  components: {
    autoSearchOrg,
    autoSearchName,
    modStorehouseForm,
    adjustStockForm
  },
  data() {
    return {
      form: this.clearForm(),
      disabled: false,
      condition: {}, // 查询条件
      wrongData: [], // table数组
      pageSearch: getCheackWrongList, // 分页查询api接口
      currentRow: ''
    }
  },
  mounted() {
    this.$nextTick(() => {
      this.loadData()
    })
  },
  methods: {
    clearForm() {
      return {
      }
    },
    loadData() {
      this.$refs.wrongList.loadData()
    },
    //单击盘点有误物资列表
    handleCurrentChange(val) {
      console.log(val)
      this.currentRow = val
    },
    //修正库位
    handleStorehouseDialog() {
      if (this.currentRow) {
        console.log(this.currentRow)
        this.$refs.modStorehouseForm.form = JSON.parse(
          JSON.stringify(this.currentRow)
        )
        this.$refs.modStorehouseForm.dialogForm = true
      } else {
        this.$message({
          type: 'error',
          message: '请选择一条数据!'
        })
      }
    },
    //调整库存
    handleStockDialog() {
      if (this.currentRow) {
        this.$refs.adjustStockForm.form = JSON.parse(
          JSON.stringify(this.currentRow)
        )
        this.$refs.adjustStockForm.dialogForm = true
      } else {
        this.$message({
          type: 'error',
          message: '请选择一条数据!'
        })
      }
    },
    handleRouterPush(val) {
      this.$store.commit('ADD_CACHED_VIEWS', val)
      this.$router.push(val.path)
    }
  }
}
</script>

<style scoped>
</style>
